package dao

import "WORKSPACE/models"

func GetallDetails() (error, []models.OrderView, int64) {
	var detailsData []models.OrderView
	var total int64
	err := db.Table("orderview").Count(&total).Find(&detailsData).Error
	return err, detailsData, total
}

func Adddetails() (error) {

	//a.BindJSON(&injurydata)
	//injurydata.Is_del = false
	//injurydata.Update_username = "系统管理员"
	//injurydata.Update_time = time.Now()
	detailsdata := models.Order_details{}
	err := db.Table("order_details").Create(&detailsdata).Error
	return err
}

func Updatedetails() (error) {

	//a.BindJSON(&injurydata)
	//injurydata.Update_username = "系统管理员"
	//injurydata.Update_time = time.Now()
	detailsdata := models.Order_details{}
	err := db.Table("order_details").Where("order_details_id = ?", detailsdata.OrderDetailsId).Updates(&detailsdata).Error
	return err
}

func Deldetails() error {
	id := "1"
	err := db.Table("order_details").Where("order_details_id = ?", id).Delete(models.Order_details{}).Error
	return err
}